//
//  MqDatabase.m
//  Meiqi
//
//  Created by TwistedFate on 16/4/8.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqDatabase.h"

@implementation MqDatabase

+ (MqDatabase *)dataBaseHandle{
    
    static MqDatabase *dataBase = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        dataBase = [[MqDatabase alloc] init];
        
    });
    
    return dataBase;
    
}

- (void)buildListWithString:(NSString *)SQLString{
    
    
    //
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
        
    NSString *sqlitePath = [path stringByAppendingPathComponent:@"MQDatabase.sqlite"];
        
    _db = [FMDatabase databaseWithPath:sqlitePath];
        
        
    NSLog(@"sqlitePath === %@", sqlitePath);
    
    
    if ([_db open]) {
            
            NSLog(@"数据路打开成功");
            
    }else{
            
            NSLog(@"数据库打开失败");
            
    }
    
    //  使用sqlite语句建表
    [_db executeUpdate:SQLString];
    
}

@end
